import django_filters
from apps.HttpTestcase.models import Ext_MethodModel


class MethodFilters(django_filters.rest_framework.FilterSet):
    """
    扩展方法过滤
    """

    # iexact表示精确匹配, 并且忽略大小写
    # icontains表示模糊查询（包含），并且忽略大小写
    # exact表示精确匹配
    name = django_filters.CharFilter(field_name='name', lookup_expr='icontains')
    ext_method = django_filters.CharFilter(field_name='ext_method', lookup_expr='icontains')
    ext_method_type = django_filters.BooleanFilter(field_name='ext_method_type', lookup_expr='exact')

    class Meta:
        model = Ext_MethodModel
        fields = ['name', 'ext_method', 'ext_method_type']